package com.lzh.chatnote.chat.utils;

import cn.hutool.core.util.StrUtil;
import com.lzh.chatnote.chat.domain.enums.GroupMemberStatusEnum;
import cn.hutool.core.lang.Pair;
import lombok.Data;

@Data
public class ChatMemberHelper {
    private static final String CURSOR_SPLIT = "_";

    public static Pair<GroupMemberStatusEnum, String> getCursorPair(String cursor) {
        GroupMemberStatusEnum queryKey = GroupMemberStatusEnum.ONLINE;
        String value = null;
        if (StrUtil.isNotBlank(cursor)) {
            String key = cursor.split(CURSOR_SPLIT)[0];
            queryKey = GroupMemberStatusEnum.of(Integer.parseInt(key));
            value = cursor.split(CURSOR_SPLIT)[1];
        }
        return Pair.of(queryKey, value);
    }


    public static String mergeCursor(GroupMemberStatusEnum statusEnum, String value) {
        return statusEnum.getActiveStatus() + CURSOR_SPLIT + value;
    }
}
